#include<stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>



/* ./hello_test r */

int main(int argc, char** argv)
{
    int fd;
	int len = 0;
	char app_buf[100];
	
    if(argc == 1)
   	{
   	  printf("Usage:\n");
	  printf("%s r   - read version from hello drv\n", argv[0]);
	  return -1;
   	}
   
   fd = open("/dev/abcxyz", O_RDWR);
   if(fd == -1)
	{
	   printf("open /dev/abcxyz err\n");
	   return -1;
	}

   if(argc == 2 && !strcmp(argv[1], "r"))
   {
	   len = read(fd, app_buf, 100);
	   if(len == -1)
		{
		   printf("read /dev/abcxyz err\n");
		   return -1;
		}
       app_buf[len - 1] = '\0';
	   
	   printf("get version from drv: %s\n", app_buf);
   }

   close(fd);
   return 0;
}
